package sctu.edu.java.year2016.team06.yuweimei.day20160603.chapter11_2;

/**
 * 新建Number类，通过类中的count()方法可得到任意两个数相乘的结果，并在调用该方法的主方法中使用try..catch语句捕捉可能发生的异常
 * Created by asus on 2016/6/4.
 */

import java.util.Scanner;

public class Number {
    public Number() {
    }

    public void count() throws MyException {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入第一个整数：");
        int a = scan.nextInt();
        System.out.println("请输入第二个整数：");
        int b = scan.nextInt();
        int result = a * b;
        System.out.println("这两个数相乘的结果是：" + result);
        MyException exception = new MyException();
        if ((int) a != a || (int) b != b) throw exception;
    }

}
